-- base_attrib
-- created by chendh
-- 天空战附加属性：天空战属性防守方固定数值变化
-- ([fire:5,speed:-5]) 代表敌方火力+5且速度-5

return {
    -- 空属性
    getEmptyProp = function()
        return {};
    end,

    -- 合并属性
    mergeSkyProp = function(data, addon)
        local result = {};

        if not data then
            result = table.copy(addon);
        else
            result = table.copy(data);

            for style, value in pairs(addon) do
                result[style] = value + (result[style] or 0);
            end
        end

        return result;
    end,

    parseDesc = function(desc, data)
        -- 按顺序替换，每次替换一个
        local attribName, amount;
        for _, key in ipairs(table.keys(data)) do
            -- 属性名称
            attribName = "airship_" .. key;
            desc = string.gsub(desc, "{attrib}", getLocStr(attribName), 1);

            -- 变化的属性，取绝对值
            amount = math.abs(data[key]);
            desc = string.gsub(desc, "{num}", amount, 1);
        end

        return desc;
    end,
};